<template>
	<view >
		<view class="logo">
			<u-image width="100%" mode="widthFix" src="@/static/logo.png"></u-image>
		</view>
		<view class="input">
			<u-form :model="form" ref="uForm">
				<u-form-item left-icon="phone-fill">
					<u-input v-model="form.username" placeholder="请输入门店账号" />
				</u-form-item>
				<u-form-item left-icon="lock-fill" >
					<u-input v-model="form.password" type="password" placeholder="请输入登录密码" />
				</u-form-item>
			</u-form>
			<view class="login-btn">
				<u-button type="success" @click="submit">登录</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					username: '',
					password: ''
				}
			}
		},
		onLoad() {
			
		},
		methods: {
			submit(){
				let form = this.form
				if(form.username == ''){
					uni.showToast({
						title: '请输入手机号码',
						icon: 'none'
					})
					return
				}
				if(form.password == ''){
					uni.showToast({
						title: '请输入登录密码',
						icon: 'none'
					})
					return
				}
				this.request.post('api-login',form).then((res) => {
					console.log(11223,res)
					if(res.data){
						uni.setStorageSync('api_token',res.data)
						uni.navigateTo({
							url: '/pages/login/parking-code'
						})
					}else{
						uni.showTabBar({
							title: '账号/密码错误',
							icon: 'none'
						})
					}
					
				}).catch((err) => {
					uni.showTabBar({
						title: '账号/密码错误',
						icon: 'none'
					})
				})
				
			}
		}
	}
</script>

<style>
	.content {
		padding: 10px;
	}

	.logo {
		padding: 10px 25%;
	}

	
	.input {
		padding: 10px 10%;
	}
	
	.login-btn{
		padding-top:15px;
	}
	
</style>
